package io.renren.modules.evaluate.service.imp;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import io.renren.common.utils.PageUtils;
import io.renren.common.utils.Query;
import io.renren.modules.evaluate.dao.EvaluationSchemeMapper;
import io.renren.modules.evaluate.entity.EvaluationSchemeEntity;
import io.renren.modules.evaluate.entity.IndexSystemMidEntity;
import io.renren.modules.evaluate.entity.SchemeIndexEntity;
import io.renren.modules.evaluate.service.EvaluationSchemeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

@Service("evaluationSchemeService")
public class EvaluationSchemeServiceImp extends ServiceImpl<EvaluationSchemeMapper, EvaluationSchemeEntity>  implements EvaluationSchemeService {

    @Autowired
    EvaluationSchemeMapper evaluationSchemeMapper;

    public List<EvaluationSchemeEntity> findById(Integer id){
           return evaluationSchemeMapper.findByid(id);
    }

    public List<EvaluationSchemeEntity> findAll(){return evaluationSchemeMapper.findall();}




    @Override
    public PageUtils queryPage(Map<String, Object> params) {
        IPage<EvaluationSchemeEntity> page = this.page(
                new Query<EvaluationSchemeEntity>().getPage(params),
                new QueryWrapper<EvaluationSchemeEntity>()
        );

        return new PageUtils(page);
    }

    @Override
    public Integer addEvaluationScheme(EvaluationSchemeEntity evaluationScheme){
        return baseMapper.addEvaluationScheme(evaluationScheme);
    }

    @Override
    public Integer addSchemeIndex(List<SchemeIndexEntity> schemeIndexEntityList, Integer schemeId){
        return baseMapper.addSchemeIndex(schemeIndexEntityList, schemeId);
    }

    @Override
    public Integer logicalDelById(Integer id){
        return baseMapper.logicalDelById(id);
    }

    @Override
    public List<EvaluationSchemeEntity> queryBySchemeName(String schemeName) {
        return baseMapper.queryBySchemeName(schemeName);
    }

    @Override
    public List<EvaluationSchemeEntity> fuzzyQueryBySchemeName(String schemeName, Long userId){
        return baseMapper.fuzzyQueryBySchemeName(schemeName, userId);
    }

    @Override
    public List<SchemeIndexEntity> queryByParentIdx(Integer schId, Integer pid){
        return baseMapper.queryByParentIdx(schId, pid);
    }

    @Override
    public List<IndexSystemMidEntity> queryByParentIdx2(Integer idxSysId, Integer pid){
        return baseMapper.queryByParentIdx2(idxSysId, pid);
    }

    @Override
    public Integer updateSchemeIndexById(List<SchemeIndexEntity> schemeIndexEntityList){
        return baseMapper.updateSchemeIndexById(schemeIndexEntityList);
    }
}
